using UnityEngine; using System.Collections; namespace EnhancedScrollerDemos.SelectionDemo { /// /// This delegate handles any changes to the selection state of the data /// /// The state of the selection public delegate void SelectedChangedDelegate(bool val); /// /// This class represents an inventory record /// public class InventoryData { /// /// The name of the inventory item /// public string itemName; /// /// The cost of the inventory item /// public int itemCost; /// /// The damage the item can do /// public int itemDamage; /// /// The armor the item provides /// public int itemDefense; /// /// The weight of the item /// public int itemWeight; /// /// This description of the inventory item /// public string itemDescription; /// /// The path to the resources folder for the sprite /// representing this inventory item /// public string spritePath; /// /// The delegate to call if the data's selection state /// has changed. This will update any views that are hooked /// to the data so that they show the proper selection state UI. /// public SelectedChangedDelegate selectedChanged; /// /// The selection state /// private bool _selected; public bool Selected { get { return _selected; } set { // if the value has changed if (_selected != value) { // update the state and call the selection handler if it exists _selected = value; if (selectedChanged != null) selectedChanged(_selected); } } } } }